import {Key} from 'react';
import { request } from "@/utils/http";
import type {
  getHosSetListParamsType,
  getHosSetListReturnType,
  postAddHospitalParamsType,
  getHosSetListItemsType,
  updateHospitalParamType
} from "./model/hospitalSetTypes";

//1.医院设置中 获取分页列表
export const getHosSetListRequest = ({ page, limit, hosname, hoscode }: getHosSetListParamsType) => {
  return request.get<any, getHosSetListReturnType>(`/admin/hosp/hospitalSet/${page}/${limit}`, {
    params: {
      hosname,
      hoscode
    }
  })
};

//2.医院设置中 新增医院请求

export const postAddHospitalRequest = (data:postAddHospitalParamsType) => {
   return request.post<any,null>("/admin/hosp/hospitalSet/save" , data)
}

//3.医院设置中 根据id获取某个详细的医院设置
export const getHospitalFromIdRequest = (id:string) => {
  return request.get<any,getHosSetListItemsType>(`/admin/hosp/hospitalSet/get/${id}`)
}

//4. 医院设置中 根据id修改数据后，再次提交修改
export const updateHosSetFromIdRequest = (data: updateHospitalParamType) => {
  return request.put<any, null>("/admin/hosp/hospitalSet/update", data)
}

//5. 医院设置中 根据id删除数据
export const deleteHosListRequest = (id:number) => {
  return request.delete<any ,null>(`/admin/hosp/hospitalSet/remove/${id}`)
}

//6. 医院设置中 批量删除
export const batchDeleteRequest = (ids:Key[]) => {
  return request.delete<any , null>("/admin/hosp/hospitalSet/batchRemove",{
    data : ids
  })
}
